//#define _CRTDBG_MAP_ALLOC
//#include <crtdbg.h>

// Precompiled header for platforms that allow it.
// Slows down compilation on other platforms, unfortunately

#ifndef PCH_H
#define PCH_H
#undef GLEW

#ifdef GLEW
#include <GL/glew.h>
#define USE_GLU
#endif

// For compilers that support precompilation, includes "wx.h".
#include <wx/wxprec.h>

#ifdef __BORLANDC__
#   pragma hdrstop
#endif

#ifndef WX_PRECOMP
    // Include your minimal set of headers here, or wx.h
#   include <wx/wx.h>
#endif

#include <wx/app.h>
#include <wx/frame.h>
#include <wx/menu.h>
#include <wx/statusbr.h>
#include <wx/splitter.h>

#include <wx/event.h>
#include <wx/dnd.h>

#include <wx/colordlg.h>
#include <wx/clrpicker.h>
#include <wx/bookctrl.h>
#include <wx/propdlg.h>
#include <wx/filepicker.h>
#include <wx/combobox.h>
#include <wx/listctrl.h>
#include <wx/spinctrl.h>

// Don't want to use registry under windows, for now, at least.
//#include <wx/config.h>
#include <wx/fileconf.h>

#include <wx/settings.h>

#include <wx/ffile.h>
#include <wx/wfstream.h>
#include <wx/filename.h>
#include <wx/stdpaths.h>

#include <wx/dynarray.h>
#include <wx/url.h>

#include <wx/glcanvas.h>

#include <wx/version.h>

#include <wx/aboutdlg.h>

//#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
//#define new DEBUG_NEW

#define APP_NAME _T("Molli")
#define APP_VERSION _T("0.99")

#define APP_NAME_FULL APP_NAME APP_VERSION

// Window title.
#define APP_TITLE APP_NAME

#endif

// Used in enough files to warrant inclusion here.
struct Color {
	union {
		struct {
			unsigned char r, g, b, a;
		};
		long uVal;
	};
	inline int operator==(const Color &c) const {
		return uVal == c.uVal;
	}
	inline int operator!=(const Color &c) const {
		return uVal != c.uVal;
	}
	inline Color &operator=(const wxColour &c) {
		r = c.Red();
		g = c.Green();
		b = c.Blue();
		a = c.Alpha();
		return *this;
	}
};

extern Color white;
extern Color black;

#define WX_COLOR(c) wxColour((c).r, (c).g, (c).b)
#define WX_BRUSH(c) wxBrush(WX_COLOR(c))

// Slightly speed up wxWidgets text drawing - reduce state changes and wx object creation.
// Could do better via object reuse, but just using these should be good enough.
#define CHANGE_BRUSH_COLOR(DC, newColor, oldColor) if ((newColor) != (oldColor)) (DC).SetBrush(WX_BRUSH((oldColor) = (newColor)));
#define CHANGE_TEXT_COLOR(DC, newColor, oldColor) if ((newColor) != (oldColor)) (DC).SetTextForeground(WX_COLOR((oldColor) = (newColor)));


#ifndef USE_GLU
#include "ThirdParty/glu/minGLU.h"
#endif
